<template>
  <div>
    <el-container>
      <el-header>&nbsp;人力资源管理系统</el-header>
      <el-container class="container">
        <el-aside width="300px">
          <Menu>

          </Menu>
        </el-aside>

        <el-container>
          <el-main>
            <el-row>
              <el-col :span="24">
                <div class="grid-content bg-purple-dark">
                  <span>
                    权限设置
                  </span>
                </div>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="5">
                <div class="grid-content bg-purple">
                  <span>
                    账号
                  </span>
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple-light">
                  <span>
                   姓名
                  </span>
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple">
                  <span>
                    密码
                  </span>
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple-light">
                  <span>
                    岗位
                  </span>
                </div>
              </el-col>

              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <span>
                    操作
                  </span>
                </div>
              </el-col>
            </el-row>
            <el-row
                :model="userFile"
                placement="top"
                v-for="(userFile, index) in userFiles" :key="index">
              <el-col :span="5">
                <div class="grid-content bg-purple">
                  {{userFile.uid}}
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple-light">
                  {{userFile.uname}}
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple">
                  {{userFile.upassword}}
                </div>
              </el-col>
              <el-col :span="5">
                <div class="grid-content bg-purple-light">
<!--                  {{userFile.upost}}-->
                  <el-select v-model="userFile.upost" placeholder="请选择" style="width: 100%">
                    <el-option
                        v-for="item in user.post"
                        :key="userFile.upost"
                        :label="item.label"
                        :value="item.value"
                    >
                    </el-option>
                  </el-select>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <el-button type="primary" round @click="submit(index)">提交</el-button>
                </div>
              </el-col>
            </el-row>
          </el-main>
        </el-container>

      </el-container>
    </el-container>
  </div>
</template>

<script>
import {defineComponent, ref} from 'vue'
import {Document, Location, Menu as IconMenu, Setting,} from '@element-plus/icons-vue'
import Menu from "@/components/Menu";

export default defineComponent({
  name: "Permissionsettings",
  components: {
    Menu,
    Location,
    Document,
    Setting,
    IconMenu,
  },

  data() {
    return {
      userFiles:{
        uid:'',
        uname:'',
        upassword:'',
        upost:'',
      },
      user:{
        post:[
          {
            value: '游客',
            label: '游客',
          },
          {
            value: '人事专员',
            label: '人事专员',
          },
          {
            value: '人事经理',
            label: '人事经理',
          },
          {
            value: '薪酬专员',
            label: '薪酬专员',
          },
          {
            value: '薪酬经理',
            label: '薪酬经理',
          },
          {
            value: '超级管理员',
            label: '超级管理员',
          },
        ]
      }
    }
  },

  methods: {
    submit(index) {
      console.log(this.userFiles[index]);
      this.axios.post('/user/changePost', this.userFiles[index]).then(res => {
        alert("修改成功");
        window.location.reload();
      });
    }
  },
  created() {
    const _this = this
    _this.axios.get("/user/permissionlist").then(res => {
      _this.userFiles=res.data.data
      console.log(res.data.data)
    })
  },
  setup() {
    const activeNames = ref(['1'])
    const handleChange = (val) => {
      console.log(val)
    }

    return {
      activeNames,
      handleChange,
    }
  }
})
</script>

<style scoped>
.el-header{
  background-color: #409EFF;
  color: #e9eef3;
  text-align: left;
  line-height: 60px;
  font-size: 30px;
}
.el-aside {
  background-color: #d3dce6;
  color: var(--el-text-color-primary);
  text-align: center;
  /*line-height: 860px;*/
}

.el-main {
  background-color: #e9eef3;
  color: var(--el-text-color-primary);
  text-align: center;
  line-height: 30px;
}

body > .el-container {
  margin-bottom: 400px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.el-row {
  margin-bottom: 20px;
}

.el-row :last-child {
  margin-bottom: 0;
}

.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

.high-row{
  min-height: 200px;
}

.container{
  min-height: 860px;
}

.line {
  width: 70%;
}

.line div {
  width: 100%;
  height: 0;
  border-top: 1px solid var(--el-border-color-base);
}

.photo-box{
  display: flex;
  width:100%;
  justify-content: center; /* 水平居中 */
  align-items: center; /* 垂直居中 */
}
.left{
  width:75%;
}
.right {
  width: 25%;
  display: flex;
  flex-direction: column; /* 垂直排列子元素 */
  align-items: center; /* 水平居中子元素 */
  justify-content: center; /* 垂直居中子元素 */
  max-height: 100%;

}

.photo-upload-container {
  text-align: center;

}

.uploaded-image-container {
  width: 170px; /* 固定宽度 */
  display: flex;
  flex-direction: column; /* 垂直排列子元素 */
  align-items: center; /* 水平居中子元素 */
  text-align: center; /* 确保内部元素水平居中 */
}

.uploaded-image {
  width: 100%;
  height: 100%;

}
</style>